package com.poseidon.pokers.ui.splash;

import android.arch.lifecycle.ViewModelProviders;
import android.databinding.Observable;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.View;

import com.luojilab.component.componentlib.router.ui.UIRouter;
import com.luojilab.router.facade.annotation.RouteNode;
import com.poseidon.pokers.R;
import com.poseidon.pokers.ui.base.MainModuleActivity;


@RouteNode(path = "/splashPage", desc = "启动页")
public class SplashActivity extends MainModuleActivity {



    private SplashActivityViewModel viewModel;

    Fragment fragment;

    FragmentTransaction ft;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewModel = ViewModelProviders.of(this,getViewModelFactory()).get(SplashActivityViewModel.class);
        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(view -> {
                    if (fragment != null) {
                        ft = getSupportFragmentManager().beginTransaction();
                        ft.remove(fragment).commit();
                        fragment = null;
                    }
                    Bundle bundle = new Bundle();
                    UIRouter.getInstance().openUri(SplashActivity.this, "DDComp://login/loginPage", bundle);
                }
        );
    }

    @Override
    protected Class getDelegateClass() {
        return SplashActivityDelegate.class;
    }

    @Override
    public void actionViewModel(View view, Object o, int actionType) {

    }




}
